﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using _5._10._1.School;

namespace _5._10._1._1.School.Tests
{
    [TestClass]
    public class CourseTests
    {
        [TestMethod]
        public void TestCourseNameWithSampleName()
        {
            Course sampleCourse = new Course("Информационни технологии");

            Assert.AreEqual("Информационни технологии", sampleCourse.Name, "Course's name initialization failed");
        }

        [TestMethod]
        public void TestIsCourseStudentsListInitialized()
        {
            Course sampleCourse = new Course("Информационни технологии");

            Assert.IsTrue(sampleCourse.Students != null, "Course's students list initialization failed");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestCourseNameWithNullValue()
        {
            Course courseWithNullName = new Course(null);
        }

        [TestMethod]
        public void TestStudentsListEntriesCountWhenNewStudentIsAdded()
        {
            Course sampleCourse = new Course("Философия");

            sampleCourse.AddStudent(new Student("Борис"));

            Assert.AreEqual(1, sampleCourse.Students.Count);
        }

        [TestMethod]
        public void TestStudentsListEntriesCountWhenNewStudentIsRemoved()
        {
            Course sampleCourse = new Course("Философия");
            Student boris = new Student("Борис");
            Student tervel = new Student("Тервел");

            sampleCourse.AddStudent(boris);
            sampleCourse.AddStudent(tervel);

            var listEntriesCount = sampleCourse.Students.Count;

            sampleCourse.RemoveStudent(tervel);

            listEntriesCount--;

            Assert.AreEqual(listEntriesCount, sampleCourse.Students.Count);
        }
    }
}
